/**
 * Copyright (C) 2013-2014 the original author or authors.
 */
package com.foreveross.bsl.common.utils.exception.handle;

import javax.ws.rs.core.MultivaluedMap;

import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;

import com.foreveross.bsl.common.utils.context.ContextThead;


/** 实现了cxf拦截器，请求之前的拦截
 * @description
 *
 * @author rening
 * @version v1.0
 *
 * @2013-7-30
 *
 */
public class CxfMessageInterceptor extends AbstractPhaseInterceptor<Message> {

	public CxfMessageInterceptor() {
		super(Phase.WRITE);
	}

	/* (non-Javadoc)
	 * @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
	 */
	@Override
	public void handleMessage(Message message) throws Fault {
		 String sessionKey = ContextThead.getThreadSessionKey();
		 MultivaluedMap<String, Object> headers = (MultivaluedMap<String, Object>)message.get(Message.PROTOCOL_HEADERS);
		 headers.putSingle("sessionKey", sessionKey);
	}

}
